2000W / 48V LLC Battery-Charger  V1.00
xmc_uart.h
Go to the documentation of this file.
1 
64 #ifndef XMC_UART_H
65 #define XMC_UART_H
66 
67 /*********************************************************************************************************************
68  * HEADER FILES
69  *********************************************************************************************************************/
70 
71 #include "xmc_usic.h"
72 
99 /*********************************************************************************************************************
100  * MACROS
101  *********************************************************************************************************************/
102 
103 #if defined(USIC0)
104 #define XMC_UART0_CH0 XMC_USIC0_CH0
105 #define XMC_UART0_CH1 XMC_USIC0_CH1
106 #endif
107 
108 #if defined(USIC1)
109 #define XMC_UART1_CH0 XMC_USIC1_CH0
110 #define XMC_UART1_CH1 XMC_USIC1_CH1
111 #endif
112 
113 #if defined(USIC2)
114 #define XMC_UART2_CH0 XMC_USIC2_CH0
115 #define XMC_UART2_CH1 XMC_USIC2_CH1
116 #endif
117 
118 /*********************************************************************************************************************
119  * ENUMS
120  *********************************************************************************************************************/
121 
125 typedef enum XMC_UART_CH_STATUS
126 {
131 
137 {
156 
160 typedef enum XMC_CH_UART_EVENT
161 {
176 
181 {
185 
189 typedef enum XMC_UART_CH_INPUT
190 {
192 #if UC_FAMILY == XMC1
193  ,
194  XMC_UART_CH_INPUT_RXD1 = 3UL,
195  XMC_UART_CH_INPUT_RXD2 = 5UL
196 #endif
198 
199 
204 {
211 
212 /*********************************************************************************************************************
213  * DATA STRUCTURES
214  *********************************************************************************************************************/
215 
219 typedef struct XMC_UART_CH_CONFIG
220 {
221  uint32_t baudrate;
222  uint8_t data_bits;
224  uint8_t frame_length;
226  uint8_t stop_bits;
227  uint8_t oversampling;
231 
232 /*********************************************************************************************************************
233  * API PROTOTYPES
234  *********************************************************************************************************************/
235 
236 #ifdef __cplusplus
237 extern "C" {
238 #endif
239 
262 void XMC_UART_CH_Init(XMC_USIC_CH_t *const channel, const XMC_UART_CH_CONFIG_t *const config);
263 
279 {
280  channel->CCR = (uint32_t)(((channel->CCR) & (~USIC_CH_CCR_MODE_Msk)) | (uint32_t)XMC_USIC_CH_OPERATING_MODE_UART);
281 }
282 
299 
323 XMC_UART_CH_STATUS_t XMC_UART_CH_SetBaudrate(XMC_USIC_CH_t *const channel, uint32_t rate, uint32_t oversampling);
324 
346 void XMC_UART_CH_Transmit(XMC_USIC_CH_t *const channel, const uint16_t data);
347 
362 uint16_t XMC_UART_CH_GetReceivedData(XMC_USIC_CH_t *const channel);
363 
384 __STATIC_INLINE void XMC_UART_CH_SetWordLength(XMC_USIC_CH_t *const channel, const uint8_t word_length)
385 {
386  XMC_USIC_CH_SetWordLength(channel, word_length);
387 }
388 
405 __STATIC_INLINE void XMC_UART_CH_SetFrameLength(XMC_USIC_CH_t *const channel, const uint8_t frame_length)
406 {
407  XMC_USIC_CH_SetFrameLength(channel, frame_length);
408 }
409 
427 void XMC_UART_CH_EnableEvent(XMC_USIC_CH_t *const channel, const uint32_t event);
428 
446 void XMC_UART_CH_DisableEvent(XMC_USIC_CH_t *const channel, const uint32_t event);
447 
466  const uint8_t service_request)
467 {
469  (uint32_t)service_request);
470 }
471 
492  const XMC_UART_CH_INTERRUPT_NODE_POINTER_t interrupt_node,
493  const uint32_t service_request)
494 {
496  (uint32_t)service_request);
497 }
498 
514 __STATIC_INLINE void XMC_UART_CH_TriggerServiceRequest(XMC_USIC_CH_t *const channel, const uint32_t service_request_line)
515 {
516  XMC_USIC_CH_TriggerServiceRequest(channel, (uint32_t)service_request_line);
517 }
518 
537 {
538  return channel->PSR_ASCMode;
539 }
540 
559 __STATIC_INLINE void XMC_UART_CH_ClearStatusFlag(XMC_USIC_CH_t *const channel, const uint32_t flag)
560 {
561  channel->PSCR = flag;
562 }
563 
585 __STATIC_INLINE void XMC_UART_CH_SetInputSource(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input, const uint8_t source)
586 {
587  channel->DXCR[input] = (uint32_t)(channel->DXCR[input] & (~(USIC_CH_DX0CR_INSW_Msk|USIC_CH_DX0CR_DSEN_Msk)));
588  XMC_USIC_CH_SetInputSource(channel, (XMC_USIC_CH_INPUT_t)input, source);
589 }
590 
606 __STATIC_INLINE void XMC_UART_CH_SetPulseLength(XMC_USIC_CH_t *const channel, const uint8_t pulse_length)
607 {
608  channel->PCR_ASCMode = (uint32_t)(channel->PCR_ASCMode & (~USIC_CH_PCR_ASCMode_PL_Msk)) |
609  ((uint32_t)pulse_length << USIC_CH_PCR_ASCMode_PL_Pos);
610 }
611 
612 
625 {
627 }
628 
641 {
642  channel->PCR_ASCMode &= (uint32_t)~USIC_CH_PCR_ASCMode_MCLK_Msk;
643 }
644 
660 __STATIC_INLINE void XMC_UART_CH_SetSamplePoint(XMC_USIC_CH_t *const channel, const uint32_t sample_point)
661 {
662  channel->PCR_ASCMode = (uint32_t)((channel->PCR_ASCMode & (uint32_t)(~USIC_CH_PCR_ASCMode_SP_Msk)) |
663  (sample_point << USIC_CH_PCR_ASCMode_SP_Pos));
664 }
665 
681 {
683 }
684 
700 {
702 }
718 {
720 }
736 {
738 }
753 {
755 }
771 {
773 }
791  const XMC_UART_CH_INPUT_t input,
792  const XMC_UART_CH_INPUT_SAMPLING_FREQ_t sampling_freq)
793 {
795 }
796 
812 {
814 }
815 
830 {
832 }
833 
834 #ifdef __cplusplus
835 }
836 #endif
837 
846 #endif
#define USIC_CH_PSR_ASCMode_RFF_Msk
Definition: XMC1400.h:3260
#define USIC_CH_PSR_ASCMode_DLIF_Msk
Definition: XMC1400.h:3268
uint16_t XMC_UART_CH_GetReceivedData(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.c:172
#define USIC_CH_PSR_ASCMode_TBIF_Msk
Definition: XMC1400.h:3272
enum XMC_UART_CH_INTERRUPT_NODE_POINTER XMC_UART_CH_INTERRUPT_NODE_POINTER_t
__STATIC_INLINE void XMC_USIC_CH_SetInputSamplingFreq(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input, const XMC_USIC_CH_INPUT_SAMPLING_FREQ_t sampling_freq)
Definition: xmc_usic.h:912
#define USIC_CH_PCR_ASCMode_SP_Pos
Definition: XMC1400.h:3091
#define USIC_CH_PCR_ASCMode_SBIEN_Msk
Definition: XMC1400.h:3082
#define USIC_CH_PSR_ASCMode_TSIF_Msk
Definition: XMC1400.h:3270
enum XMC_USIC_CH_INPUT XMC_USIC_CH_INPUT_t
__STATIC_INLINE void XMC_USIC_CH_SetFrameLength(XMC_USIC_CH_t *const channel, const uint8_t frame_length)
Definition: xmc_usic.h:1094
__STATIC_INLINE void XMC_UART_CH_SetInterruptNodePointer(XMC_USIC_CH_t *const channel, const uint8_t service_request)
Definition: xmc_uart.h:465
__STATIC_INLINE void XMC_UART_CH_SetFrameLength(XMC_USIC_CH_t *const channel, const uint8_t frame_length)
Definition: xmc_uart.h:405
__STATIC_INLINE void XMC_UART_CH_EnableMasterClock(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.h:624
void XMC_USIC_CH_SetInterruptNodePointer(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INTERRUPT_NODE_POINTER_t interrupt_node, const uint32_t service_request)
Definition: xmc_usic.c:272
__STATIC_INLINE void XMC_USIC_CH_EnableInputSync(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:876
__STATIC_INLINE void XMC_UART_CH_DisableInputDigitalFilter(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input)
Definition: xmc_uart.h:735
__STATIC_INLINE void XMC_UART_CH_DisableInputSync(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input)
Definition: xmc_uart.h:770
void XMC_UART_CH_Transmit(XMC_USIC_CH_t *const channel, const uint16_t data)
Definition: xmc_uart.c:150
XMC_UART_CH_STATUS_t XMC_UART_CH_Stop(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.c:189
__STATIC_INLINE void XMC_USIC_CH_SetStartTransmisionMode(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_START_TRANSMISION_MODE_t start_transmision_mode)
Definition: xmc_usic.h:1229
#define USIC_CH_PSR_ASCMode_RIF_Msk
Definition: XMC1400.h:3274
#define USIC_CH_PSR_ASCMode_FER1_Msk
Definition: XMC1400.h:3258
#define USIC_CH_PCR_ASCMode_FEIEN_Msk
Definition: XMC1400.h:3088
__STATIC_INLINE void XMC_UART_CH_DisableMasterClock(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.h:640
__STATIC_INLINE void XMC_UART_CH_EnableDataTransmission(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.h:811
__IO uint32_t CCR
Definition: xmc_usic.h:504
__STATIC_INLINE void XMC_UART_CH_SetWordLength(XMC_USIC_CH_t *const channel, const uint8_t word_length)
Definition: xmc_uart.h:384
uint32_t baudrate
Definition: xmc_uart.h:221
__STATIC_INLINE void XMC_UART_CH_SetPulseLength(XMC_USIC_CH_t *const channel, const uint8_t pulse_length)
Definition: xmc_uart.h:606
__STATIC_INLINE void XMC_USIC_CH_EnableInputInversion(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:768
enum XMC_USIC_CH_PARITY_MODE XMC_USIC_CH_PARITY_MODE_t
__STATIC_INLINE void XMC_USIC_CH_SetWordLength(XMC_USIC_CH_t *const channel, const uint8_t word_length)
Definition: xmc_usic.h:1017
struct XMC_UART_CH_CONFIG XMC_UART_CH_CONFIG_t
#define USIC_CH_PSR_ASCMode_BUSY_Msk
Definition: XMC1400.h:3264
uint8_t data_bits
Definition: xmc_uart.h:222
#define USIC_CH_CCR_BRGIEN_Msk
Definition: XMC1400.h:3202
enum XMC_USIC_CH_INPUT_SAMPLING_FREQ XMC_USIC_CH_INPUT_SAMPLING_FREQ_t
__STATIC_INLINE void XMC_USIC_CH_TriggerServiceRequest(XMC_USIC_CH_t *const channel, const uint32_t service_request_line)
Definition: xmc_usic.h:1348
__STATIC_INLINE void XMC_UART_CH_SetInputSource(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input, const uint8_t source)
Definition: xmc_uart.h:585
#define USIC_CH_PSR_ASCMode_RNS_Msk
Definition: XMC1400.h:3254
enum XMC_USIC_CH_INTERRUPT_NODE_POINTER XMC_USIC_CH_INTERRUPT_NODE_POINTER_t
__STATIC_INLINE void XMC_UART_CH_DisableInputInversion(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input)
Definition: xmc_uart.h:699
uint8_t frame_length
Definition: xmc_uart.h:224
XMC_UART_CH_STATUS_FLAG
Definition: xmc_uart.h:136
#define USIC_CH_PSR_ASCMode_COL_Msk
Definition: XMC1400.h:3252
__STATIC_INLINE void XMC_UART_CH_EnableInputSync(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input)
Definition: xmc_uart.h:752
__STATIC_INLINE void XMC_UART_CH_SetSamplePoint(XMC_USIC_CH_t *const channel, const uint32_t sample_point)
Definition: xmc_uart.h:660
#define USIC_CH_PCR_ASCMode_CDEN_Msk
Definition: XMC1400.h:3084
XMC_UART_CH_INPUT
Definition: xmc_uart.h:189
XMC_CH_UART_EVENT
Definition: xmc_uart.h:160
#define USIC_CH_DX0CR_DSEN_Msk
Definition: XMC1400.h:2854
uint8_t stop_bits
Definition: xmc_uart.h:226
#define USIC_CH_CCR_DLIEN_Msk
Definition: XMC1400.h:3192
#define USIC_CH_CCR_TSIEN_Msk
Definition: XMC1400.h:3194
__STATIC_INLINE void XMC_UART_CH_ClearStatusFlag(XMC_USIC_CH_t *const channel, const uint32_t flag)
Definition: xmc_uart.h:559
enum XMC_CH_UART_EVENT XMC_UART_CH_EVENT_t
uint8_t oversampling
Definition: xmc_uart.h:227
__STATIC_INLINE void XMC_UART_CH_SelectInterruptNodePointer(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INTERRUPT_NODE_POINTER_t interrupt_node, const uint32_t service_request)
Definition: xmc_uart.h:491
#define USIC_CH_CCR_RSIEN_Msk
Definition: XMC1400.h:3190
#define USIC_CH_PSR_ASCMode_RSIF_Msk
Definition: XMC1400.h:3266
enum XMC_UART_CH_STATUS XMC_UART_CH_STATUS_t
__STATIC_INLINE void XMC_USIC_CH_DisableInputDigitalFilter(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:857
#define USIC_CH_CCR_AIEN_Msk
Definition: XMC1400.h:3200
#define USIC_CH_DX0CR_INSW_Msk
Definition: XMC1400.h:2850
#define USIC_CH_PCR_ASCMode_MCLK_Msk
Definition: XMC1400.h:3100
__STATIC_INLINE void XMC_USIC_CH_DisableInputInversion(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:787
#define USIC_CH_CCR_TBIEN_Msk
Definition: XMC1400.h:3196
#define USIC_CH_PCR_ASCMode_SP_Msk
Definition: XMC1400.h:3092
#define USIC_CH_PSR_ASCMode_FER0_Msk
Definition: XMC1400.h:3256
__IO uint32_t PSR_ASCMode
Definition: xmc_usic.h:512
void XMC_UART_CH_DisableEvent(XMC_USIC_CH_t *const channel, const uint32_t event)
Definition: xmc_uart.c:212
enum XMC_UART_CH_STATUS_FLAG XMC_UART_CH_STATUS_FLAG_t
__IO uint32_t DXCR[6]
Definition: xmc_usic.h:493
#define USIC_CH_PSR_ASCMode_TFF_Msk
Definition: XMC1400.h:3262
__STATIC_INLINE void XMC_USIC_CH_DisableInputSync(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:894
XMC_UART_CH_STATUS_t XMC_UART_CH_SetBaudrate(XMC_USIC_CH_t *const channel, uint32_t rate, uint32_t oversampling)
Definition: xmc_uart.c:134
#define USIC_CH_PSR_ASCMode_BRGIF_Msk
Definition: XMC1400.h:3278
__STATIC_INLINE void XMC_UART_CH_EnableInputDigitalFilter(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input)
Definition: xmc_uart.h:717
enum XMC_UART_CH_INPUT_SAMPLING_FREQ XMC_UART_CH_INPUT_SAMPLING_FREQ_t
__STATIC_INLINE void XMC_USIC_CH_EnableInputDigitalFilter(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:839
#define USIC_CH_PCR_ASCMode_RNIEN_Msk
Definition: XMC1400.h:3086
__STATIC_INLINE void XMC_USIC_CH_SetInputSource(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input, const uint8_t source)
Definition: xmc_usic.h:708
__O uint32_t PSCR
Definition: xmc_usic.h:514
#define USIC_CH_PCR_ASCMode_FFIEN_Msk
Definition: XMC1400.h:3090
XMC_USIC_CH_PARITY_MODE_t parity_mode
Definition: xmc_uart.h:228
#define USIC_CH_PSR_ASCMode_TXIDLE_Msk
Definition: XMC1400.h:3246
enum XMC_UART_CH_INPUT XMC_UART_CH_INPUT_t
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
__STATIC_INLINE void XMC_UART_CH_DisableDataTransmission(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.h:829
#define USIC_CH_CCR_RIEN_Msk
Definition: XMC1400.h:3198
void XMC_UART_CH_EnableEvent(XMC_USIC_CH_t *const channel, const uint32_t event)
Definition: xmc_uart.c:206
XMC_UART_CH_INTERRUPT_NODE_POINTER
Definition: xmc_uart.h:203
#define USIC_CH_CCR_MODE_Msk
Definition: XMC1400.h:3184
#define USIC_CH_PCR_ASCMode_PL_Msk
Definition: XMC1400.h:3094
XMC_UART_CH_STATUS
Definition: xmc_uart.h:125
XMC_UART_CH_INPUT_SAMPLING_FREQ
Definition: xmc_uart.h:180
void XMC_UART_CH_Init(XMC_USIC_CH_t *const channel, const XMC_UART_CH_CONFIG_t *const config)
Definition: xmc_uart.c:78
__STATIC_INLINE void XMC_UART_CH_Start(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.h:278
__STATIC_INLINE void XMC_UART_CH_EnableInputInversion(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input)
Definition: xmc_uart.h:680
__IO uint32_t PCR_ASCMode
Definition: xmc_usic.h:502
#define USIC_CH_PSR_ASCMode_SBD_Msk
Definition: XMC1400.h:3250
__STATIC_INLINE void XMC_UART_CH_TriggerServiceRequest(XMC_USIC_CH_t *const channel, const uint32_t service_request_line)
Definition: xmc_uart.h:514
__STATIC_INLINE uint32_t XMC_UART_CH_GetStatusFlag(XMC_USIC_CH_t *const channel)
Definition: xmc_uart.h:536
#define USIC_CH_PSR_ASCMode_RXIDLE_Msk
Definition: XMC1400.h:3248
#define USIC_CH_PCR_ASCMode_PL_Pos
Definition: XMC1400.h:3093
__STATIC_INLINE void XMC_UART_CH_SetInputSamplingFreq(XMC_USIC_CH_t *const channel, const XMC_UART_CH_INPUT_t input, const XMC_UART_CH_INPUT_SAMPLING_FREQ_t sampling_freq)
Definition: xmc_uart.h:790
#define USIC_CH_PSR_ASCMode_AIF_Msk
Definition: XMC1400.h:3276